Param( [Parameter(Mandatory = $true)] [URI]$uri, [Parameter()] [string]$csvFile = ".\input.csv", [Parameter()] [string]$username = "", [Parameter()] [string]$password = "" ) # Set credentials if ($username -eq "") { $credentials = Get-Credential } else { $credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, (ConvertTo-SecureString -String $password -AsPlainText -Force) } # Connect to Liquit. $context = Connect-LiquitWorkspace -URI $uri -Credential $credentials; # Read packages from CSV file $apps = Import-Csv $csvFile; # Loop through the packages foreach ($app in $apps) { # Detect package type if ($app.Target.StartsWith("http://", "CurrentCultureIgnoreCase") -or $app.Target.StartsWith("https://", "CurrentCultureIgnoreCase")) { $type = 'Web' } else { $type = 'Launch' } Write-Host "Importing package with name ""$($app.Name)"" as type ""$type""" # Determine Target type. try { # Create package. $package = New-LiquitPackage -Name $app.Name -Type $type -Offline ($type -eq "Web") -Web ($type -eq "Web") } catch { # Only throw if the error message was an duplicate entry if (($_.Exception).Code -eq "Request_DuplicateResource") { # Find package by name. $package = Get-LiquitPackage | Where-Object { $_.Name -eq $app.Name } } else { throw; } } # Create a new empty snapshot (if it doesn't exist) $snapshot = $package | New-LiquitPackageSnapshot $actionSet = $snapshot | New-LiquitActionSet -Type Launch # Add Web package if ($type -eq "Web") { # Add action. $action = $actionSet | New-LiquitAction -Name "Open URL" -Type "openurl" -Settings @{ url = $app.Target; browser = 0 } -Context User -Enabled $true; } else { # Add Filter Set $filterSet = $snapshot | New-LiquitFilterSet # Add File Exists Filter $filter = $filterSet | New-LiquitFilter -Type "fileexists" -Settings @{path= $app.Target} -Value "true" -Operator Equal # Add action. $action = $actionSet | New-LiquitAction -Name "Start Process" -Type "processstart" -Settings @{ name = $app.Target} -Context User -Enabled $true; } # Publish package snapshot $snapshot | Publish-LiquitPackageSnapshot -Name "Imported by PowerShell" -stage Production }